class Solution {
public:
  bool judgeCircle(string moves) {
    if (moves.empty())
      return true;

    int x = 0, y = 0;
    for (int i = 0; i < moves.size(); i++) {
      move(moves.at(i), x, y);
    }

    return (x == 0) && (y == 0);
  }

  void move(char direction, int &x, int &y) {
    switch (direction) {
    case 'U':
      y++;
      break;
    case 'D':
      y--;
      break;
    case 'R':
      x--;
      break;
    case 'L':
      x++;
      break;
    default:
      break;
    }
  }
};